#!/usr/bin/env node

const version = require('../package.json').version
const execute = require('child_process').execSync
const {
  DEFAULT_LOCAL_ENS_ADDRESS,
  DEFAULT_LOCAL_IPFS_GATEWAY,
} = require('./config/local')

execute('rimraf ./public', { stdio: 'inherit' })
execute(`copy-aragon-ui-assets -n aragon-ui ./public`, {
  stdio: 'inherit',
})

process.env.ARAGON_PACKAGE_VERSION = version
process.env.ARAGON_ETH_NETWORK_TYPE = 'local'
process.env.ARAGON_ENS_REGISTRY_ADDRESS = DEFAULT_LOCAL_ENS_ADDRESS
process.env.ARAGON_IPFS_GATEWAY = DEFAULT_LOCAL_IPFS_GATEWAY
process.env.ARAGON_APP_LOCATOR = 'ipfs'

execute(
  `parcel build src/index.html --out-dir ./public --public-url ./ --no-cache`,
  { stdio: 'inherit' }
)
